import { camera } from "./camera";
import { clock } from "./clock";
import { controls } from "./controls";
import gui from "./gui";
import { resizeHandle } from "./handles";
import { axesHelper, cameraHelper } from "./helper";
import { ambientLight } from "./light";
import { createCity } from "./mesh/city";
import { plane } from "./mesh/plane/planeMesh";
import { renderer } from "./renderer";
import { scene } from "./scene";

export class ThreeSmartCity {
  scene = scene;
  camera = camera;
  renderer = renderer;
  controls = controls;
  gui=gui;
  clock=clock

  constructor() {
    this.init();
  }

  init() {
    this.scene.add(this.camera);
    this.scene.add(ambientLight);
    this.scene.add(axesHelper);
    // this.scene.add(cameraHelper);

    // 添加物体
    // this.scene.add(plane);
    createCity()

    window.addEventListener("resize", resizeHandle);
  }
  animate() {
    // 修复this指向
    // let time = this.clock.getElapsedTime()
    // console.log(time)
    this.controls.update()
    this.camera.updateProjectionMatrix();
    requestAnimationFrame(this.animate.bind(this));
    this.renderer.render(this.scene, this.camera);
  }
}
